package com.coolweather.news_app;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.coolweather.news_app.gson.News;

import java.util.List;

public class CategoryAdapter extends RecyclerView.Adapter<NewsTypeViewHolder> {

    private List<Category> mNewsTypeList;

    public CategoryAdapter(List<Category> NewsTypeList) {
        mNewsTypeList = NewsTypeList;
    }

    @NonNull
    @Override
    public NewsTypeViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.news_category_item,parent,false);
        NewsTypeViewHolder newsTypeViewHolder = new NewsTypeViewHolder(view);
        return newsTypeViewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull NewsTypeViewHolder newsTypeViewHolder, int position) {
        Category category = mNewsTypeList.get(position);
        newsTypeViewHolder.newsType.setText(category.getNewsType());

    }

    @Override
    public int getItemCount() {
        return mNewsTypeList.size();
    }
}
